<html>
	<head>
		<meta charset=utf-8>
		<title>My first three.js app</title>
		<style>
			* { margin: 0; padding: 0}
		</style>
	</head>
	<body>
            <script src="../js/three.js"></script>
		<script>
            /*
                格式：LatheGeometry(points, segments, phiStart, phiLength)
                points	Vector2表示的坐标数据组成的数组
                segments	圆周方向细分数，默认12
                phiStart	开始角度,默认0
                phiLength	旋转角度，默认2π
            */

            /*
            *创建场景对象
            */ 
            let scene = new THREE.Scene();
            /*
            *创建旋转网格模型
            */
            let points = [
                new THREE.Vector2(50,60),
                new THREE.Vector2(25,0),
                new THREE.Vector2(50,-60)
            ];
            let geometry = new THREE.LatheGeometry(points,60);
            let material=new THREE.MeshPhongMaterial({
                color:0x00ffff,//三角面颜色
                side:THREE.DoubleSide//两面可见
            });//材质对象
            material.wireframe = false;//线条模式渲染(查看细分数)
            let mesh=new THREE.Mesh(geometry,material);//旋转网格模型对象
            scene.add(mesh);//旋转网格模型添加到场景中

            /**
            * 光源设置
            */
            // 点光源
            let point = new THREE.PointLight(0xffffff); // 0xffffff 定义光照强度
            point.position.set(400, 200, 300); // 点光源位置
            scene.add(point); // 点光源添加到场景中
            // 环境光
            let ambient = new THREE.AmbientLight(0x444444);
            scene.add(ambient);
            
            /*
             *相机设置 
            */
            let width = window.innerWidth;
            let height = window.innerHeight;
            let k = width / height; // 窗口宽高比
            let s = 200; // 三维场景缩放系数
            let camera = new THREE.OrthographicCamera (-s*k,s*k, s,-s,1,1000);
            camera.position.set(100, 100, 100); // 设置相机位置
            camera.lookAt(scene.position); // 设置相机方向（指向的场景对象）

            /*
            * 创建渲染器对象
            */
            let renderer = new THREE.WebGLRenderer({
                antialias:true,       //是否开启反锯齿
            });
            renderer.setSize(width, height);
            renderer.setClearColor(0xb9d3ff,1);//设置背景颜色
            document.body.appendChild( renderer.domElement );// body元素中插入canvas对象
            renderer.render(scene,camera);// 执行渲染操作
		</script>
	</body>
</html>